package cn.wizzer.app.web.modules.controllers.user;


import cn.wizzer.app.user.modules.models.GroupReport;
import cn.wizzer.app.user.modules.services.GroupReportService;
import cn.wizzer.app.web.commons.filter.ApiTokenFilter;
import cn.wizzer.framework.util.Result;
import cn.wizzer.framework.util.param.ParamVerify;
import com.alibaba.dubbo.config.annotation.Reference;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.Mvcs;
import org.nutz.mvc.annotation.*;

/**
 * 用户举报群
 *
 * @author .
 */
@IocBean
@At("/api/user/groupReport")
public class ApiGroupReportController {
    @Inject
    @Reference
    private GroupReportService groupReportService;


    @At("/add")
    @Ok("json")
    @Filters(@By(type = ApiTokenFilter.class))
    public Object add(@ParamVerify(required = true, name = "groupId") String groupId,
                      @ParamVerify(required = true, name = "content") String content) {
        String appid = Mvcs.getReq().getHeader("appid");
        GroupReport groupReport = new GroupReport();
        groupReport.setUserId(appid);
        groupReport.setGroupId(groupId);
        groupReport.setContent(content);
        groupReportService.insert(groupReport);
        return Result.success();
    }

}
